<?php
namespace app\mysql\controller;  // 必须继承于app 第二个是具体的应用名  例 t5/note/tp
use think\Controller;
//use think\Request;
use think\config;


use think\Db;
class Index2 extends Controller
{

	
  
public function index(){
	$res = Db::connect(
		[
		// 数据库类型
	'type'            => 'mysql',
	// 服务器地址
	'hostname'        => 'localhost',  //127.0.0.1
	// 数据库名
	'database'        => 'test',
	// 用户名
	'username'        => 'root',
	// 密码
	'password'        => '886400',
	// 端口
	'hostport'        => '3306',
	// 连接dsn
	'dsn'             => '',
	// 数据库连接参数
	'params'          => [],
	// 数据库编码默认采用utf8
	'charset'         => 'utf8',
	// 数据库表前缀
	'prefix'          => 'test_',
		]
			);
			return $res;

}


/**
 * 实验联通
 * http://www.hyhthjk.com.cn/note.php/mysql/Index2/index1
 */
public function index1(){
	
	$res=$this->index();

			$data =	$res->query('select * from test_user' );
			dump($data);

			echo $res->getlastsql();  // model 下获得最后一条sql

}

/**
 * 创建数据表http://www.hyhthjk.com.cn/note.php/mysql/Index2/index2
 */
public function index2(){
	$res = $this->index();
	$sql = <<<sql
	CREATE TABLE `test_one` (
	`id` int(11) NOT NULL AUTO_INCREMENT,
	`name` char(200) DEFAULT NULL COMMENT '章节名称',
	`contents` text COMMENT '章节文字',
	`next` int(11) DEFAULT NULL COMMENT '下一章地址',
	`pid` int(11) DEFAULT NULL COMMENT '小说名称',
	`novel_url` char(50) DEFAULT NULL COMMENT '小说章节地址',
	PRIMARY KEY (`id`)
	) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;		
sql;
	//上面注意sql 要顶头写
	dump($res->execute($sql));

}
 
/**
 * 创建临时表
 */
public function index3(){
	$res = $this->index();
	$sql = <<<sql
	CREATE TEMPORARY TABLE `test_two` (
	`id` int(11) NOT NULL AUTO_INCREMENT,
	`name` char(200) DEFAULT NULL COMMENT '章节名称',
	`contents` text COMMENT '章节文字',
	`next` int(11) DEFAULT NULL COMMENT '下一章地址',
	`pid` int(11) DEFAULT NULL COMMENT '小说名称',
	`novel_url` char(50) DEFAULT NULL COMMENT '小说章节地址',
	PRIMARY KEY (`id`)
	) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;		
sql;
	//上面注意sql 要顶头写
	dump($res->execute($sql));

}


/**
 * 删除数据表
 */
public function index4(){
	$res = $this->index();
	$sql ="DROP TABLE test_one";
	dump($res->execute($sql));

}
/**
 * 插入一行
 * http://www.hyhthjk.com.cn/note.php/mysql/Index2/index5
 */
public function index5(){
 $res = $this->index();
$v_name = '王wf1';
$v_time = date('Y-m-d H:i:s');
$v_age = 54;
$age = 'age';
$name = 'name';
$time = 'time';
$table = 'test_user';
//   $data = $res->execute("insert into test_user($name) values ('$v_name')"); 单数据 对
   $data = $res->execute("insert into $table($name,$age,$time) values ('$v_name',$v_age,'$v_time')");
 //echo $res->getlastsql();
 dump($data);
 $this->index6();
}

public function index6(){
echo'
<pre>
<hr/>
$res = $this->index();
$v_name = \'王wf1\';
$v_time = date(\'Y-m-d H:i:s\');
$v_age = 54;
$age = \'age\';
$name = \'name\';
$time = \'time\';
$table = \'test_user\';
//   $data = $res->execute("insert into test_user($name) values (\'$v_name\')"); 单数据 对
   $data = $res->execute("insert into $table($name,$age,$time) values (\'$v_name\',$v_age,\'$v_time\')");

</pre>
';
}

/**
 * 查询
 */
public function index7(){
	$res = $this->index();
	$table = 'test_user';
	$data = $res->query("select * from $table");
	dump($data);

}


/**
 * 批量插入数据 数据来源于另一张表中的部分数据
 * http://www.hyhthjk.com.cn/note.php/mysql/Index2/index8
 */
public function index8(){
	$res = $this->index();
	$table = 'test_user';
	// $data = $res->execute("insert into $table($name,$age,$time) values ('$v_name',$v_age,'$v_time')");
	$openid = 'openid';
	$name = 'name';
	$nickname = 'nickname';
	$data = $res->execute("insert into $table($openid,$name) select $openid,$nickname from test_kehu");
	echo $res->getlastsql();
	$this->index9();
	dump($data);
}

public function index9(){
	echo'
	<pre>
	<hr/>
	$table = \'test_user\';
	$openid = \'openid\';
	$name = \'name\';
	$nickname = \'nickname\';
	$data = $res->execute("insert into $table($openid,$name) select $openid,$nickname from test_kehu");
	echo $res->getlastsql();
	echo \'返回 插入了多少条数据\';
	</pre>
	';
}


/**
 * where 列之间可以运算
 * http://www.hyhthjk.com.cn/note.php/mysql/Index2/index10
 */
public function index10(){
	$res = $this->index();
	$table = 'test_user';
	$id = 'id';
	$name = 'name';
	$height = 'height';
	$low = 'low';
	$cha = '50';   // hieght-low的差值
	$logic ='>'; 
	$where = $height.'-'.$low.$logic.$cha;
	$data = $res->query("select $id,$name,$height,$low  from $table where $where");
	$this->index11();
	echo $res->getlastsql();
	dump($data);

}

public function index11(){
	echo'
	<pre>
	<hr/>
	$table = \'test_user\';
	$id = \'id\';
	$name = \'name\';
	$height = \'height\';
	$low = \'low\';
	$cha = \'50\';   // hieght-low的差值
	$logic =\'>\'; 
	$where = $height.\'-\'.$low.$logic.$cha;
	$data = $res->query("select $id,$name  from $table where $where");
	<hr/>
	</pre>
	';
	
	//echo '看这里';
}

/**
 * in在..集合之内
 */
public function index12(){
    $res = $this->index();
	$table = 'test_user';
	$id = 'id';
	$low = 'low';
	$name = 'name';
	$in = array('35','18','88');
	$in = implode(",", $in);
	// dump($in);
	$this->index13();
	$data = $res->query("select $id,$name  from $table where $low in ($in)");
	dump($data);

}

public function index13(){
  echo'
  <pre>
  <hr/>
	$table = \'test_user\';
	$id = \'id\';
	$low = \'low\';
	$name = \'name\';
	$in = array(\'35\',\'18\',\'88\');  // 一般传来的是数组
	$in = implode(",", $in);            // 数组转字符串
	$data = $res->query("select $id,$name  from $table where $low in ($in)");
  <hr/>
	</pre> 
    ';
}


/**
 * between 在。。之间
 */
public function index14(){
	$res = $this->index();
	$table = 'test_user';
	$id = 'id';
	$low = 'low';
	$name = 'name';
	$between = 'between';
	$from = '34';
	$to = '88';
	$data = $res->query("select $id,$name from $table where $low $between $from and $to");
	$this->index15();
	dump($data);

}

public function index15(){
	echo'
	<pre>
	<hr/>
	$table = \'test_user\';
	$id = \'id\';
	$low = \'low\';
	$name = \'name\';
	$between = \'between\';
	$from = \'34\';
	$to = \'88\';
	$data = $res->query("select $id,$name from $table where $low $between $from and $to");
	<hr/>
	</pre>
	';

}

/**
 * 查出价格最贵max的商品
 */
public function index16(){
	$res = $this->index();
	$table = 'test_user';
	$id = 'id';
	$height = 'height';
	$data = $res->query("select max($height) from $table");
	$this->index17();
    dump($data);
}

public function index17(){
	echo'
	<pre>
	<hr/>
	$table = \'test_user\';
	$id = \'id\';
	$height = \'height\';
	$data = $res->query("select max($height) from $table");
	<hr/>
	</pre>
	';
}
	
/**
 * 查询每个栏目group下最贵max的商品价格
 */
public function index18(){
	$res = $this->index();
	$table = 'test_user';
	$id = 'id';
	$cat_id = 'cat_id';
	$height = 'height';
	$data = $res->query("select $cat_id,max($height) from $table group by $cat_id");
	$this->index19();
	dump($data);

}

public function index19(){
	echo'
	<pre>
	<hr/>
	$table = \'test_user\';
	$id = \'id\';
	$cat_id = \'cat_id\';
	$height = \'height\';
	$data = $res->query("select $cat_id,max($height) from $table group by $cat_id");
	<hr/>
	</pre>
	';

}

/**
 *统计所有商品数量的总和sum
 *数量用height列代替  
 */
public function index20(){
	$res = $this->index();
	$table = 'test_user';
	$id = 'id';
    $height = 'height';
	$data = $res->query("select sum($height) from $table");
	$this->index21();
	dump($data);
}

public function index21(){
	echo'
	<pre>
	<hr/>
	$table = \'test_user\';
	$id = \'id\';
    $height = \'height\';
	$data = $res->query("select sum($height) from $table");
	<hr/>
	</pre>
	';
}

/**
 * 统计共有多少条数据count
 */
public function index22(){
	$res = $this->index();
	$table = 'test_user';
	$data = $res->query("select count(*) from $table");
	$this->index23();
	dump($data);
}

public function index23(){
	echo'
	<pre>
	<hr/>
	$table = \'test_user\';
	$data = $res->query("select count(*) from $table");
	<hr/>
	</pre>
	';
}

/**
 * 统计每个栏目下积压的货款 分组 和列运算 统计sum
 * 假设 height 是单价  low 是 数量 栏目是cat_id
 */
public function index24(){
	$res = $this->index();
	$table = 'test_user';
    $cat_id = 'cat_id';
	$height = 'height';
	$low = 'low';
	$data = $res->query("select $cat_id,sum($height*$low) from $table group by $cat_id");
	$this->index25();
	dump($data);
}

public function index25(){
	echo'
	<pre>
	<hr/>
	$table = \'test_user\';
    $cat_id = \'cat_id\';
	$height = \'height\';
	$low = \'low\';
	$data = $res->query("select $cat_id,sum($height*$low) from $table group by $cat_id");
	<hr/>
	</pre>
	';
}

/**
 * order
 */
public function index26(){
	$res = $this->index();
	$table = 'test_user';
	$id = 'id';
	$height = 'height';
	$cat_id = 'cat_id';
	$where = $cat_id.'=3';
	$order = 'height';
	$shunxu = 'desc';  //排序规则  由大到小desc asc
	$order1 = 'name';
	$shunxu1 = 'asc';
	$data = $res->query("select $id,$height,$order1 from $table where $where order by $order1 $shunxu1,$order $shunxu");
	$this->index27();
	echo $res->getlastsql();
	dump($data);
}

public function index27(){
	echo'
	<pre>
	<hr/>
	$table = \'test_user\';
	$id = \'id\';
	$height = \'height\';
	$cat_id = \'cat_id\';
	$where = $cat_id.\'=3\';
	$order = \'height\';
	$shunxu = \'desc\';  //排序规则  由大到小desc asc
	$order1 = \'name\';
	$shunxu1 = \'asc\';
	$data = $res->query("select $id,$height,$order1 from $table where $where order by $order1 $shunxu1,$order $shunxu");
	echo $res->getlastsql();
	<hr/>
	</pre>
	';
}

/**
 * limit
 */
public function index28(){
	$res = $this->index();
	$table = 'test_user';
	$id = 'id';
	$height = 'height';
	$order = 'height';
	$shunxu = 'desc';  //排序规则  由大到小desc asc
	$limit_pianyi = '3';  //从第几个值开始取
	$limit_n = '5';  // 取5个值
	
	$data = $res->query("select $id,$height from $table order by $height $shunxu limit $limit_pianyi,$limit_n");
	$this->index29();
	echo $res->getlastsql();
	dump($data);
}

public function index29(){
	echo'
	<pre>
	</hr>
	$table = \'test_user\';
	$id = \'id\';
	$height = \'height\';
	$order = \'height\';
	$shunxu = \'desc\';  //排序规则  由大到小desc asc
	$limit_pianyi = \'3\';  //从第几个值开始取
	$limit_n = \'5\';  // 取5个值
	
	$data = $res->query("select $id,$height from $table order by $height $shunxu limit $limit_pianyi,$limit_n");
	$this->index27();
	echo $res->getlastsql();
	<hr/>
	</pre>
	';
	
}

/**
 * 建立临时表，填入数据
 */
public function index30(){
	$res = $this->index();
	$openid = 'openid';
	$name = 'name';
	$cat_id = 'cat_id';
	//  CREATE  TABLE test_two like test_user
		$sql = <<<sql
		CREATE TEMPORARY TABLE `test_two` like test_user
sql;
	//上面注意sql 要顶头写
	 $res->execute($sql);
	 $res->execute("insert into test_two ($openid,$name,$cat_id) select $openid,$name,$cat_id from test_user order by cat_id desc");
	 $data = $res->query("select * from test_two");
	 echo $res->getlastsql();
	 $this->index31();
	dump($data);

}

public function index31(){
	echo'
	<pre>
	<hr/>
	$openid = \'openid\';
	$name = \'name\';
	$cat_id = \'cat_id\';
	//  CREATE  TABLE test_two like test_user
		$sql = <<<sql
		CREATE TEMPORARY TABLE `test_two` like test_user
sql;
	//上面注意sql 要顶头写
	 $res->execute($sql);
	 $res->execute("insert into test_two ($openid,$name,$cat_id) select $openid,$name,$cat_id from test_user order by cat_id desc");
	 $data = $res->query("select * from test_two");
	<hr/>
	</pre>
	';
}

/**
 * where 子查询
 */
public function index32(){
	$res = $this->index();
	$id = 'id';
	$height = 'height';
	$cat_id = 'cat_id';
	$table = 'test_user';
	$data = $res->query("select $id,$height from $table where $id = (select max($id) from $table)");
	echo $res->getlastsql();
	$this->index33();
	dump($data);
}

public function index33(){
	echo'
	<pre>
	<hr/>
	$id = \'id\';
	$height = \'height\';
	$cat_id = \'cat_id\';
	$table = \'test_user\';
	$data = $res->query("select $id,$height from $table where $id = (select max($id) from $table)");
	<hr/>
	</pre>
	';
}

/**
 * 查询每个分组group栏目下最大max的身高
 */
public function index34(){
	$res = $this->index();
	$cat_id = 'cat_id';
	$table = 'test_user';
	$height = 'height';
	$id = 'id';
	$data = $res->query("select $cat_id,$id,max($height) from $table group by $cat_id");
	$this->index35();
	dump($data);
}

public function index35(){
	echo'
	<pre>
	<hr/>
	$cat_id = \'cat_id\';
	$table = \'test_user\';
	$height = \'height\';
	$id = \'id\';
	$data = $res->query("select $cat_id,$id,max($height) from $table group by $cat_id");
	<hr/>
	</pre>
	';
}


/***
 * union
 * http://www.hyhthjk.com.cn/note.php/mysql/Index2/index36
 */
public function index36(){
	$res = $this->index();
	$table = 'test_user';
	$height = 'height';
	$cat_id = 'cat_id';
	$id = 'id';
	$logic1 = '>';
	$nub1 ='120';
	$where1 = $height.$logic1.$nub1;
	$logic2 = '<';
	$nub2 = '60'; 
	$where2 = $height.$logic2.$nub2;
	// $data = $res->query("select $cat_id,$id,$height from $table where $where1 ");
	// $data = $res->query("select $cat_id,$id,$height from $table where $where2 and height>0");
	$data = $res->query("(select $cat_id,$id,$height from $table where $where1) union (select $cat_id,$id,$height from $table where $where2 and height>0)");
	$this->index37();
	echo $res->getlastsql();
    dump($data);
}

public function index37(){
	echo'
	<pre>
	<hr/>
	$table = \'test_user\';
	$height = \'height\';
	$cat_id = \'cat_id\';
	$id = \'id\';
	$logic1 = \'>\';
	$nub1 =\'120\';
	$where1 = $height.$logic1.$nub1;
	$logic2 = \'<\';
	$nub2 = \'60\'; 
	$where2 = $height.$logic2.$nub2;
	// $data = $res->query("select $cat_id,$id,$height from $table where $where1 ");
	// $data = $res->query("select $cat_id,$id,$height from $table where $where2 and height>0");
    $data = $res->query("(select $cat_id,$id,$height from $table where $where1) union (select $cat_id,$id,$height from $table where $where2 and height>0)");
	<hr/>
	</pre>
	';
}

/**
 * union 相加两张表的列值，表结构可以不同，列名可以不对应，按name分组group num相加运算
 */
public function index38(){
	$res = $this->index();
	$name = 'name';
	$num = 'num';
	 $data = $res->query("select $name,sum($num) from (select name,num from test_a union select name,num from test_b) as tmp group by name");
	//$data = $res->query("select name,num from test_a union select name,num from test_b");
	$this->index39();
dump($data);
		}

public function index39(){
	echo'
	<pre>
	<hr/>
	$name = \'name\';
	$num = \'num\';
		$data = $res->query("select $name,sum($num) from (select name,num from test_a union select name,num from test_b) as tmp group by name");
	<hr/>
	</pre>
	';
		}
/**
 * 两表相乘
 */
public function index40(){
	$res = $this->index();
	$table1 = 'test_a';
	$table2 = 'test_b';
	$data =   $data = $res->query("select * from $table1,$table2");
	$this->index41();
	dump($data);
}

public function index41(){
	echo'
	<pre>
	<hr/>
	$table1 = \'test_a\';
	$table2 = \'test_b\';
	$data =   $data = $res->query("select * from $table1,$table2");
	<hr/>
	</pre>
	';
}

/**
 * 左连接
 */
public function index42(){
	$res = $this->index();
	$table1 = 'test_a';
	$table2 = 'test_b';
	$id = 'id';
	$name = 'name';
	$num = 'num';
	$data = $res->query("select $id,$table1.$name,$table1.$num,$table2.$num as num2 from $table2 left join $table1 on $table2.$name = $table1.$name");
	$this->index43();
	echo $res->getlastsql();
	dump($data);
}

public function index43(){
	echo'
	<pre>
	原句一 适用于phpmyadmin  SELECT stock_jbzb.id,stock_jbzb.code FROM stock_jbzb LEFT JOIN stock_name ON stock_name.id=stock_jbzb.id;
	注意 只要两个表有相同的列 就要列出表明
	<hr/>
	$table1 = \'test_a\';
	$table2 = \'test_b\';
	$id = \'id\';
	$name = \'name\';
	$num = \'num\';
	$data = $res->query("select $id,<span style="color:red">$table1.$name</span>,$table1.$num,<span style="color:red">$table2.$num as num2</span> from $table2 left join $table1 on $table2.$name = $table1.$name");
	<hr/>
	</pre>
	';
}

/**
 * 创建视图
 * http://www.hyhthjk.com.cn/note.php/mysql/Index2/index44
 */
public function index44(){
	$res = $this->index();
	$table = 'test_user';
	$res = $this->index();
	$name = 'name';
	$cat_id = 'cat_id';
	$height = 'height';
	$logic = '>';
	$num = '100';
	$where = $height.$logic.$num;
	// 视图名字为name1    create view name1 as select name,cat_id,height from test_user where height>100;	

	$sql = <<<sql
	create view name1 as select $name,$cat_id,$height from $table where $where;	
sql;
$res->execute($sql);
//dump出这张表
$this->index50();
$this->index45();
	}




	public function index45(){
		echo'
		<pre>
		<hr/>
		$table1 = \'test_a\';
		$res = $this->index();
		// 视图名字为name1
		$sql = <<<sql
		create view name1 as select name,cat_id,height from test_user where height>100;	
	sql;
	$res->execute($sql);
	<hr/>
	</pre>
	';
		}

/**
 *删除 视图 NAME1
 */
public function index46(){
	$res = $this->index();
	$sql ="DROP VIEW name1";
	dump($res->execute($sql));
}
public function index47(){
	echo'
	<pre>
	<hr/>
	$sql ="DROP VIEW name1";
	dump($res->execute($sql));
	<hr/>
	</pre>
	';
}

/**
 * s视图创建临时表
 */
public function index48(){
	$res = $this->index();
	$table = 'test_user';

	$name = 'name';
	$cat_id = 'cat_id';
	$height = 'height';
	$logic = '>';
	$num = '100';
	$where = $height.$logic.$num;
	// 视图名字为name1    create altorethm=temptable view name2 as select name,cat_id,height from test_user where height>100;	
	                                       
	$sql = <<<sql
	create altorethm = temptable view name2 as select $name,$cat_id,$height from $table where $where;	
sql;
echo $sql;
$res->execute($sql);
$this->index49();
	}

	public function index49(){
		echo'
		<pre>
		<hr/>
		$res = $this->index();
		$table = \'test_user\';
		$res = $this->index();
		$name = \'name\';
		$cat_id = \'cat_id\';
		$height = \'height\';
		$logic = \'>\';
		$num = \'100\';
		$where = $height.$logic.$num;
		// 视图名字为name1    create view name2 as select name,cat_id,height from test_user where height>100;	
	
		$sql = <<<sql
		create altorethm=temptable view name2 as select $name,$cat_id,$height from $table where $where;	
	sql;
	$res->execute($sql);
	<hr/>
	</pre>
	';
		}


	public function index50(){
		$res = $this->index();
		$data = $res->query("select * from name1");
		dump($data);
	}



/**
 *删除 视图 NAME1
 */
public function index51(){
	$res = $this->index();
	$sql ="DROP VIEW name2";
	dump($res->execute($sql));
}


//查询 一个字段 多个模糊关键字
public function index52(){
	$res = $this->index();
    $sql = "SELECT * FROM note_listt WHERE id LIKE '%5%' AND id LIKE '%3%'";
	$data = Db::query($sql);
	$this->index53();
	dump($data);
}

public function index53(){
echo'
<pre>
查询id字段 即含有3 又含有5
$sql = "SELECT * FROM note_listt WHERE id LIKE \'%5%\' AND id LIKE \'%3%\'";
$data = Db::query($sql);

</pre>
';

}


//查询表1分组项为 次新和短线关注 并且表2为中线开仓的股票 而且 字段中要含有两个表的字段（左连接 join）
public function index54(){
	//http://www.hyhthjk.com.cn/note.php/mysql/Index2/index54
	$res = Db::connect(
		[
		// 数据库类型
	'type'            => 'mysql',
	// 服务器地址
	'hostname'        => 'localhost',  //127.0.0.1
	// 数据库名
	'database'        => 'stock',
	// 用户名
	'username'        => 'root',
	// 密码
	'password'        => '886400',
	// 端口
	'hostport'        => '3306',
	// 连接dsn
	'dsn'             => '',
	// 数据库连接参数
	'params'          => [],
	// 数据库编码默认采用utf8
	'charset'         => 'utf8',
	// 数据库表前缀
	'prefix'          => 'stock_',
		]
			);

			$sql = "SELECT stock_jbzb.id,stock_jbzb.code,stock_jbzb.time,stock_jbzb.name,stock_name.group1 AS group2 
		FROM stock_jbzb LEFT JOIN stock_name ON stock_name.code=stock_jbzb.code 
		WHERE stock_jbzb.p2up = 1 AND stock_jbzb.code in (SELECT stock_name.code FROM stock_name WHERE group1 LIKE '%老%' AND group1 LIKE '%持有%')
		ORDER BY stock_jbzb.pOrdershow DESC";
		 dump($res->query($sql));
		 $this->index55();
}

public function index55(){
  echo'<pre>
  $sql = "SELECT stock_jbzb.id,stock_jbzb.code,stock_jbzb.time,stock_jbzb.name,stock_name.group1 AS group2 
		FROM stock_jbzb LEFT JOIN stock_name ON stock_name.code=stock_jbzb.code 
		WHERE stock_jbzb.p2up = 1 AND stock_jbzb.code in (SELECT stock_name.code FROM stock_name WHERE group1 LIKE \'%老%\' AND group1 LIKE \'%持有%\')
		ORDER BY stock_jbzb.pOrdershow DESC";
		 dump($res->query($sql));
	查询 联合显示的某几项 和表二的某项
		用表1左连接表2 链接关系是code 相同
		条件是 股票的代码 必须在 表1 p2uo = 1（短线开仓） 并且 在表2必须是 次新股同时也是长线关注股
		排序
 
  </pre>';

}

//给test_one 表添加一列
public function index56(){
	$res = $this->index();
	$sql = <<<sql
	alter table `test_one` add heig int;		
sql;
	//上面注意sql 要顶头写
	dump($res->execute($sql));

}



/**
 * 测试
 *  http://www.hyhthjk.com.cn/note.php/mysql/Index2/text
 */
	public function text(){
		$res = $this->index();
		$data = $res->query("select * from name1");
		dump($data);
	}

	/**
 * 删除数据表
 */
public function text2(){
	$res = $this->index();
	$sql ="DROP VIEW name2";
	dump($res->execute($sql));

}



}